package com.weixin.IOStream;

import org.junit.Test;

import java.io.*;
import java.nio.ByteBuffer;

/**
 * @ClassName IoTest
 * @Description
 * @date 2022/2/17 11:15
 * @author: wx
 * @Version 1.0
 */
public class IoTest {
    @Test
    public void copePicture() throws IOException {
        //使用流处理字节数据
        //指定文件
        File src_file = new File("a.png");
        File dis_file = new File("b.png");
        //造流
        FileInputStream fileInputStream = new FileInputStream(src_file);
        FileOutputStream fileOutputStream = new FileOutputStream(dis_file);

        //复制图片
        byte[] bytes = new byte[20];
        int len;
        while ((len = fileInputStream.read(bytes)) != -1) {
            fileOutputStream.write(bytes, 0, len);
        }
        fileInputStream.close();
        fileOutputStream.close();
    }
}
